<template>
  <div>
    <el-row class="tac">
      <el-col :span="12">
        <el-menu
          default-active="0"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          collapse-transition
        >
          <el-menu-item index="0">
            <i class="el-icon-s-order"></i>
            <span slot="title" @click="toHead">系统首页</span>
          </el-menu-item>
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>商品管理</span>
            </template>
            <el-menu-item index="1-1" @click="click">所有</el-menu-item>
            <el-submenu index="1-2">
              <template slot="title">品牌分类</template>
              <el-menu-item
                :index="'1-2-'+index"
                @click="click(item)"
                v-for="(item,index) in mongoList"
                :key="index"
              >{{item}}</el-menu-item>
            </el-submenu>
            <el-submenu index="1-3">
              <template slot="title">上架管理</template>
              <el-menu-item index="1-3-1" @click="newUpdata">新品上架</el-menu-item>
            </el-submenu>
          </el-submenu>
          <el-menu-item index="2">
            <i class="el-icon-s-order"></i>
            <span slot="title">订单管理</span>
          </el-menu-item>
          <el-menu-item index="3">
            <i class="el-icon-document"></i>
            <span slot="title">广告信息</span>
          </el-menu-item>
          <el-menu-item index="4">
            <i class="el-icon-setting"></i>
            <span slot="title">用户管理</span>
          </el-menu-item>
          <el-menu-item index="5">
            <i class="el-icon-user"></i>
            <span slot="title">个人中心</span>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>

<script>

import data from "../../../assets/data/data";
import store from "../../../store/index";
export default {
  data() {
    return {
      mongoList: []
    };
  },
  mounted() {
    this.mongoList = data.mongoList;
  },
  methods: {
    //   首页
    toHead() {
      this.$router.push(`/`);
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    // 商品列表路由跳转
    async click(e) {
      // console.log(e.index);//不传值进来的时候这里显示的是这个标签的index属性
      // console.log(e);//传值进来的时候显示的是传进来的值
      store.state.isShow = false;
      setTimeout(async () => {
        store.state.isShow = true;
              if (e.index == "1-1") {
        this.$router.push(`/shopList?key=all`);
      } else {

        this.$router.push(`/shopList?key=${e}`);
      }
      }, 10);
    },
    // 新品上市 
    newUpdata(){
      this.$router.push("/edit")
    }
  }
};
</script>

<style scoped>
.el-col {
  width: 100%;
}
.el-menu {
  height: 500px;
}
</style>